package data;

import com.EntityName;
import com.google.appengine.api.datastore.Entity;


public class SubPayment extends AbstractData {
	private long id = -1;
	private long hotelId;
	private double amount;
	private Payment parentPayment;
	private String parentPaymentString;
	private long folioId;

	
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public long getHotelId() {
		return hotelId;
	}
	public void setHotelId(long hotelId) {
		this.hotelId = hotelId;
	}
	public double getAmount() {
		return amount;
	}
	public void setAmount(double amount) {
		this.amount = amount;
	}
	public Payment getParentPayment() {
		return parentPayment;
	}
	public void setParentPayment(Payment parentPayment) {
		this.parentPayment = parentPayment;
	}
	public String getParentPaymentString() {
		return parentPaymentString;
	}
	public void setParentPaymentString(String parentPaymentString) {
		this.parentPaymentString = parentPaymentString;
	}
	public long getFolioId() {
		return folioId;
	}
	public void setFolioId(long folioId) {
		this.folioId = folioId;
	}
	
	public Entity getEntity() {
		Entity item;
		if(this.key == null)
			item = new Entity(EntityName.SubPayment);
		else
			item = new Entity(this.key);

		item.setProperty("HotelId", this.hotelId);
		item.setProperty("amount", this.amount);	
		item.setProperty("folioId", this.folioId);
		item.setProperty("ParentPayment", this.parentPaymentString);
		return item;
	}

	public void setEntity(Entity entity) {
		this.id = entity.getKey().getId();
		this.hotelId = (Long) entity.getProperty("HotelId");
		this.amount = (Double) entity.getProperty("amount");
		this.folioId = (Long) entity.getProperty("folioId");
		this.parentPaymentString = (String) entity.getProperty("ParentPayment");
		this.key = entity.getKey();
	}
	
	public void LoadData() {
		if (this.id > -1) {
			Entity entity = LoadData(EntityName.SubPayment, this.id);
			setEntity(entity);
		}
	}
}
